package com.goldcn.goods.controller;

import com.goldcn.enumeration.GoodsStateEnum;
import com.goldcn.goods.dto.*;
import com.goldcn.goods.service.GoodsClassifyCommissionService;
import com.goldcn.goods.service.GoodsIndexService;
import com.goldcn.goods.service.GoodsLabelService;
import com.goldcn.goods.service.GoodsService;
import com.goldcn.goods.vo.*;
import com.goldcn.interceptor.SystemContext;
import com.goldcn.order.dto.UserIDGoodsByDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/11/15.
 */
@RestController
@RequestMapping("/goods")
@Api(value = "商品", description = "商品微服务")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private GoodsClassifyCommissionService goodsClassifyCommissionService;
    @Autowired
    private GoodsLabelService goodsLabelService;
    @Autowired
    private GoodsIndexService goodsIndexService;


    @ApiOperation(value = "添加或修改商品信息")
    @RequestMapping(value = "/operation", method = RequestMethod.POST)
    public Object operateGoods(@RequestBody GoodsDetailsVo goodsDetailsVo) {
        return goodsService.operateGoods(goodsDetailsVo);
    }

    @ApiOperation(value = "查看商品详情")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
    })
    @RequestMapping(value = "/detail/{goodsID}", method = RequestMethod.GET)
    public Object queryGoodsDetail(@PathVariable Long goodsID, HttpServletRequest request) {
        boolean isAndroid = false;
        String browseOS = getOsAndBrowserInfo(request);
        if (browseOS != null && browseOS.indexOf("okhttp") > 0)
            isAndroid = true;
        return goodsService.queryGoodsDetail(goodsID, isAndroid, false);
    }

    @ApiOperation(value = "查看商品详情_编辑")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),})
    @RequestMapping(value = "/detailEdit/{goodsID}", method = RequestMethod.GET)
    public Object queryGoodsDetailEdit(@PathVariable Long goodsID, HttpServletRequest request) {
        boolean isAndroid = false;
        String browseOS = getOsAndBrowserInfo(request);
        if (browseOS != null && browseOS.indexOf("okhttp") > 0)
            isAndroid = true;
        return goodsService.queryGoodsDetail(goodsID, isAndroid, true);
    }


    @ApiOperation(value = "查看商品详情v2;会员价")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
            @ApiImplicitParam(paramType = "path", name = "userID", required = true, value = "用户ID", defaultValue = "X123")
    })
    @RequestMapping(value = "/detail/{goodsID}/{userID}", method = RequestMethod.GET)
    public Object queryGoodsDetailv2(@PathVariable Long goodsID, @PathVariable Long userID, HttpServletRequest request) {
        boolean isAndroid = false;
        String browseOS = getOsAndBrowserInfo(request);
        if (browseOS != null && browseOS.indexOf("okhttp") > 0)
            isAndroid = true;
        return goodsService.queryGoodsDetailv2(goodsID, userID, isAndroid);
    }

    @ApiOperation(value = "根据款号加载商品详情")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "prdNo", required = true, value = "商品款号", defaultValue = "X123"),
    })
    @RequestMapping(value = "/detailprono/{prdNo}", method = RequestMethod.GET)
    public Object queryGoodsDetailByProNo(@PathVariable String prdNo, HttpServletRequest request) {
        Long goodsID = goodsService.selectByPrdNo(prdNo);
        /*boolean isAndroid = false;
        String browseOS = getOsAndBrowserInfo(request);
        if (browseOS != null && browseOS.indexOf("okhttp") > 0)
            isAndroid = true;*/
        //借货不做过滤
        return goodsService.queryGoodsDetail(goodsID, false, false);
    }

    @ApiOperation(value = "分页查询list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "pageSize", required = true, value = "分页大小", defaultValue = "5"),
            @ApiImplicitParam(paramType = "path", name = "pageNum", required = true, value = "当前页", defaultValue = "1"),
    })
    @RequestMapping(value = "/list/{pageSize}/{pageNum}", method = RequestMethod.POST)
    public Object conditionQueryGoods(@RequestBody QueryGoodsDto queryGoodsDto,
                                      @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        return goodsService.conditionQueryGoods(queryGoodsDto, pageNum, pageSize);
    }

    @ApiOperation(value = "查询sku信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
    })
    @RequestMapping(value = "/sku/{goodsID}", method = RequestMethod.GET)
    public Object queryGoodsSkuInfo(@PathVariable Long goodsID) {
        return goodsService.queryGoodsSkuInfo(goodsID, null, null);
    }

    @ApiOperation(value = "修改商品sku库存和价格 status:0仅库存1仅价格2库存和价格")
    @RequestMapping(value = "/sku", method = RequestMethod.PUT)
    public Object operateGoodsSkuInventory(@RequestBody GoodsSkuVo goodsSkuVo) {
        return goodsService.operateGoodsSkuInventory(goodsSkuVo);
    }

    @ApiOperation(value = "操作商品状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "state", required = true, value = "商品状态(Approved:通过 Unapprove:未通过 Unshelve:下架 Shelve:上架 Detele:删除)", defaultValue = "Unapprove"),
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
    })
    @RequestMapping(value = "/state/{state}/{goodsID}", method = RequestMethod.GET)
    public Object operateGoodsState(@PathVariable Long goodsID, @PathVariable String state,
                                    @RequestParam(value = "labelID", required = false) String labelID) {
        GoodsStateEnum stateEnum = Enum.valueOf(GoodsStateEnum.class, state);
        return goodsService.operateGoodsState(goodsID, stateEnum, labelID);
    }

    @ApiOperation(value = "操作商品状态for中收")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "state", required = true, value = "商品状态(Approved:通过 Unapprove:未通过 Unshelve:下架 Shelve:上架 Detele:删除)", defaultValue = "Unapprove"),
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
    })
    @RequestMapping(value = "/state/{state}/{goodsID}", method = RequestMethod.POST)
    public Object operateGoodsStateForVal(@PathVariable Long goodsID, @PathVariable String state, @RequestBody Map<String, Object> map,
                                          @RequestParam(value = "labelID", required = false) String labelID) {
        GoodsStateEnum stateEnum = Enum.valueOf(GoodsStateEnum.class, state);
        return goodsService.operateGoodsStateCopy(goodsID, stateEnum, labelID, map);
    }

    //TODO 平台审核商品
    @ApiOperation(value = "操作商品状态添加价格 中银金行")
    @RequestMapping(value = "/stateV2", method = RequestMethod.POST)
    public Object operateGoodsStateV2(@RequestBody GoodsPriceDto goodsPriceDto) {
        GoodsStateEnum stateEnum = Enum.valueOf(GoodsStateEnum.class, goodsPriceDto.getState());
        return goodsService.operateGoodsStateV2Copy(goodsPriceDto.getGoodsID(), stateEnum, goodsPriceDto.getLabelID(), goodsPriceDto.getGoodsSkuList(), goodsPriceDto);
    }


    @ApiOperation(value = "查询分类对应的扣点值")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "clazzID", required = true, value = "标签的clazzID", defaultValue = "X123")
    })
    @RequestMapping(value = "/rate/{clazzID}", method = RequestMethod.GET)
    public Object getClassifyVal(@PathVariable String clazzID) {
        return goodsClassifyCommissionService.getGoodsClassifyValByClazzID(clazzID);
    }


    //TODO 新增或者修改分类对应的扣点值
    @ApiOperation(value = "新增或者修改分类对应的扣点值")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "clazzID", required = true, value = "标签的clazzID", defaultValue = "X123"),
            @ApiImplicitParam(paramType = "path", name = "val", required = true, value = "标签的扣点值", defaultValue = "33")
    })
    @RequestMapping(value = "/rate/{clazzID}/{val}", method = RequestMethod.GET)
    public Object updateClassify(@PathVariable String clazzID, @PathVariable Integer val) {
        return goodsClassifyCommissionService.operateClassifyValByClazzID(clazzID, val);
    }

    @ApiOperation(value = "得到最下级的扣点值")
    @RequestMapping(value = "/rate", method = RequestMethod.POST)
    public Object getClassifyVal(@RequestBody @Validated QueryRateDto queryRateDto) {
        //TODO 待处理
        return goodsClassifyCommissionService.getRateByClazzID(queryRateDto.getLevelOne(), queryRateDto.getLevelTwo());
    }

    @ApiOperation(value = "查询标签列表")
    @RequestMapping(value = "/label/list", method = RequestMethod.GET)
    public Object getLabelList() {
        return goodsLabelService.getGoodsLabelList(SystemContext.getCompanyID());
    }


    @ApiOperation(value = "店铺版本2018：店铺标签列表")
    @RequestMapping(value = "/label/listV2/{companyID}", method = RequestMethod.GET)
    public Object getLabelListV2(@PathVariable Long companyID) {
        return goodsLabelService.getGoodsLabelList(companyID);
    }

    @ApiOperation(value = "新增标签信息")
    @RequestMapping(value = "/label", method = RequestMethod.POST)
    public Object addLabelList(@RequestBody GoodsLabelVo goodsLabelVo) {
        return goodsLabelService.addGoodsLabel(goodsLabelVo);
    }

    @ApiOperation(value = "删除标签信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "labelID", required = true, value = "标签的labelID", defaultValue = "X123"),
    })
    @RequestMapping(value = "/label/{labelID}", method = RequestMethod.DELETE)
    public Object delLabel(@PathVariable Long labelID) {
        return goodsLabelService.deleteByPrimaryKey(labelID);
    }

    @ApiOperation(value = "修改标签信息")
    @RequestMapping(value = "/label", method = RequestMethod.PUT)
    public Object updateLabel(@RequestBody GoodsLabelVo goodsLabel) {
        return goodsLabelService.updateByGoodsLabel(goodsLabel);
    }

    @ApiOperation(value = "查询标签信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "labelID", required = true, value = "标签的labelID", defaultValue = "a123"),
    })
    @RequestMapping(value = "/label/{labelID}", method = RequestMethod.GET)
    public Object getLabel(@PathVariable Long labelID) {
        return goodsLabelService.selectByPrimaryKey(labelID);
    }

    @ApiOperation(value = "查询扣点值集合")
    @RequestMapping(value = "/rateList", method = RequestMethod.POST)
    public Object getClassifyVal(@RequestBody List<String> clazzIDs) {
        return goodsClassifyCommissionService.selectByClazzIDListCopy(clazzIDs);
    }

    @ApiOperation(value = "查询商品-价格 集合")
    @RequestMapping(value = "/priceList", method = RequestMethod.POST)
    public Object operateGoodsSkuInventory(@RequestBody List<Long> goodsIDs) {
        return goodsService.queryMultipleGoodsPrice(goodsIDs, null);
    }

    @ApiOperation(value = "查询商品-价格 集合v2")
    @RequestMapping(value = "/priceListv2/{userID}", method = RequestMethod.POST)
    public Object operateGoodsSkuInventoryv2(@RequestBody List<Long> goodsIDs, @PathVariable Long userID) {
        return goodsService.queryMultipleGoodsPrice(goodsIDs, userID);
    }

    @ApiOperation(value = "查询 商品销量排行榜，供应商在售商品数排行榜，平台商品总数")
    @RequestMapping(value = "/rank", method = RequestMethod.GET)
    public Object queryRank() {
        return goodsService.querySupplierRank();
    }

    @ApiOperation(value = "索引纠错记录接口")
    @RequestMapping(value = "/esLog", method = RequestMethod.POST)
    public Object recordEsLog(@RequestBody List<GoodsIndexInfoVo> indexList) {
        return goodsIndexService.correction(indexList);
    }

    @ApiOperation(value = "商品索引重新添加")
    @RequestMapping(value = "/indexMove", method = RequestMethod.GET)
    public Object indexMove() {
        goodsService.indexMove();
        return "ssss";
    }

    @ApiOperation(value = "商品索引删除")
    @RequestMapping(value = "/indexDelete", method = RequestMethod.GET)
    public Object indexDelete() {
        goodsService.indexDelete();
        return "ssss";
    }

    @ApiOperation(value = "初始化商品索引")
    @RequestMapping(value = "/initAllIndex", method = RequestMethod.GET)
    public Object initAllIndex() {
        goodsService.initAllIndex();
        return "ssss";
    }

    @ApiOperation(value = "商品状态;SoldOut:已售罄,Unshelve:已下架,NoApprove;审核中,Shelve:已经上架,Unapprove:审核未通过")
    @RequestMapping(value = "/retState", method = RequestMethod.POST)
    public Object retState(@RequestBody Long skuID) {
        return goodsService.retState(skuID);
    }


    @ApiOperation(value = "获取平台品类类别，移动端分类品类设置用")
    @RequestMapping(value = "/clazzListV2", method = RequestMethod.GET)
    public Object getPlatformClassList() {
        return goodsService.getPlatformClassList(null);
    }

    @ApiOperation(value = "获取平台品类类别，移动端分类品类设置用 2018")
    @RequestMapping(value = "/clazzListV3/{shopID}", method = RequestMethod.GET)
    public Object getPlatformClassList(@PathVariable Long shopID) {
        return goodsService.getPlatformClassList(shopID);
    }


    @ApiOperation(value = "根据平台获取分类下的属性列表")
    @RequestMapping(value = "/clazzAttrList", method = RequestMethod.POST)
    public Object getPlatformAttrList(@RequestBody ClazzObjDto list) {
        return goodsService.getPlatformAttrList(list);
    }

    @ApiOperation(value = "获取平台指定品类所有下级，移动端分类品类设置用")
    @RequestMapping(value = "/clazzListPullByParId/{clazzId}", method = RequestMethod.GET)
    public Object getClassifyListPullById(@PathVariable String clazzId) {
        return goodsService.getClassifyListPullById(clazzId);
    }


    @ApiOperation(value = "一级分类下拉列表")
    @RequestMapping(value = "/clazzListPull", method = RequestMethod.GET)
    public Object clazzListPull() {
        return goodsService.clazzListPull(null);
    }

    @ApiOperation(value = "一级分类下拉列表")
    @RequestMapping(value = "/clazzListPullByShop/{shopID}", method = RequestMethod.GET)
    public Object clazzListPull(@PathVariable Long shopID) {
        return goodsService.clazzListPull(shopID);
    }


    @ApiOperation(value = "二级分类列表根据一级分类ID查询")
    @RequestMapping(value = "/clazzListByParId/{clazzId}", method = RequestMethod.GET)
    public Object getClassifyListById(@PathVariable String clazzId) {
        return goodsService.getClassifyListById(clazzId);
    }

    @ApiOperation(value = "二级分类列表根据一级分类ID查询,蓝帝版本专用")
    @RequestMapping(value = "/clazzListByParIdV2/{clazzId}", method = RequestMethod.GET)
    public Object getClassifyListByIdV2(@PathVariable String clazzId) {
        return goodsService.getClassifyListByIdV2(clazzId);
    }

    @ApiOperation(value = "获取平台所有二级品类 中银金行设置用")
    @RequestMapping(value = "/clazzLevel2List", method = RequestMethod.GET)
    public Object getClassifyListById() {
        return goodsService.getPlatformClassListLevel2();
    }

    @ApiOperation(value = "批量修改标签信息代理供货比")
    @RequestMapping(value = "/label/discountRate", method = RequestMethod.PUT)
    public Object updatDiscountRate(@RequestBody List<ClazzRateVo> list) {
        return goodsClassifyCommissionService.updateDiscountRateList(list);
    }

    @ApiOperation(value = "b2b查询用户商品折扣")
    @RequestMapping(value = "/b2b/userLevel/discountRate", method = RequestMethod.POST)
    public Object getUserLevel(@RequestBody UserIDGoodsByDto userIDGoodsByDto) {
        return goodsService.goodsDiscountRate(userIDGoodsByDto, true);
    }

    @ApiOperation(value = "查询用户商品折扣")
    @RequestMapping(value = "/userLevel/discountRate", method = RequestMethod.POST)
    public Object getUserLevel2(@RequestBody UserIDGoodsByDto userIDGoodsByDto) {
        return goodsService.goodsDiscountRate(userIDGoodsByDto, false);
    }


    @ApiOperation(value = "商品索引更新companyID")
    @RequestMapping(value = "/indexCompanyID", method = RequestMethod.GET)
    public Object indexCompanyID() {
        goodsService.indexCompanyID();
        return "ok";
    }


    /**
     * 获取操作系统,浏览器及浏览器版本信息
     *
     * @param request
     * @return
     */
    private static String getOsAndBrowserInfo(HttpServletRequest request) {
        String browserDetails = request.getHeader("User-Agent");
        String userAgent = browserDetails;
        String user = userAgent.toLowerCase();

        String os = "";
        String browser = "";

        //=================OS Info=======================
        if (userAgent.toLowerCase().indexOf("windows") >= 0) {
            os = "Windows";
        } else if (userAgent.toLowerCase().indexOf("mac") >= 0) {
            os = "Mac";
        } else if (userAgent.toLowerCase().indexOf("x11") >= 0) {
            os = "Unix";
        } else if (userAgent.toLowerCase().indexOf("android") >= 0) {
            os = "Android";
        } else if (userAgent.toLowerCase().indexOf("iphone") >= 0) {
            os = "IPhone";
        } else {
            os = "UnKnown, More-Info: " + userAgent;
        }
        //===============Browser===========================
        if (user.contains("edge")) {
            browser = (userAgent.substring(userAgent.indexOf("Edge")).split(" ")[0]).replace("/", "-");
        } else if (user.contains("msie")) {
            String substring = userAgent.substring(userAgent.indexOf("MSIE")).split(";")[0];
            browser = substring.split(" ")[0].replace("MSIE", "IE") + "-" + substring.split(" ")[1];
        } else if (user.contains("safari") && user.contains("version")) {
            browser = (userAgent.substring(userAgent.indexOf("Safari")).split(" ")[0]).split("/")[0]
                    + "-" + (userAgent.substring(userAgent.indexOf("Version")).split(" ")[0]).split("/")[1];
        } else if (user.contains("opr") || user.contains("opera")) {
            if (user.contains("opera")) {
                browser = (userAgent.substring(userAgent.indexOf("Opera")).split(" ")[0]).split("/")[0]
                        + "-" + (userAgent.substring(userAgent.indexOf("Version")).split(" ")[0]).split("/")[1];
            } else if (user.contains("opr")) {
                browser = ((userAgent.substring(userAgent.indexOf("OPR")).split(" ")[0]).replace("/", "-"))
                        .replace("OPR", "Opera");
            }

        } else if (user.contains("chrome")) {
            browser = (userAgent.substring(userAgent.indexOf("Chrome")).split(" ")[0]).replace("/", "-");
        } else if ((user.indexOf("mozilla/7.0") > -1) || (user.indexOf("netscape6") != -1) ||
                (user.indexOf("mozilla/4.7") != -1) || (user.indexOf("mozilla/4.78") != -1) ||
                (user.indexOf("mozilla/4.08") != -1) || (user.indexOf("mozilla/3") != -1)) {
            browser = "Netscape-?";

        } else if (user.contains("firefox")) {
            browser = (userAgent.substring(userAgent.indexOf("Firefox")).split(" ")[0]).replace("/", "-");
        } else if (user.contains("rv")) {
            String IEVersion = (userAgent.substring(userAgent.indexOf("rv")).split(" ")[0]).replace("rv:", "-");
            browser = "IE" + IEVersion.substring(0, IEVersion.length() - 1);
        } else {
            browser = "UnKnown, More-Info: " + userAgent;
        }

        return os + " --- " + browser;
    }

    @ApiOperation(value = "删除所有商品")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", name = "companyID", dataType = "Long", required = true, value = "companyID", defaultValue = "")})
    @RequestMapping(value = "/delAllGoods", method = RequestMethod.POST)
    public Object delAllGoods(@RequestBody Long companyID) {
        return goodsService.delAllGoods(companyID);
    }

    @ApiOperation(value = "删除指定商品")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "query", name = "goodsID", dataType = "Long", required = true, value = "goodsID", defaultValue = "")})
    @RequestMapping(value = "/delGoodsByGoodsID", method = RequestMethod.POST)
    public Object delGoodsByGoodsID(@RequestBody Long goodsID) {
        return goodsService.delGoodsByGoodsID(goodsID);
    }


    @ApiOperation(value = "批量删除指定商品")
    @RequestMapping(value = "/delBatchGoodsByGoodsID", method = RequestMethod.POST)
    public Object delGoodsByGoodsID(@RequestBody List<Long> goodsIDs) {
        return goodsService.delBatchGoodsByGoodsID(goodsIDs);
    }


    @ApiOperation(value = "修改ES商品实时金价类型")
    @RequestMapping(value = "/updateIndexingToGoldPrice", method = RequestMethod.POST)
    public Object updateIndexingToGoldPrice() {
        return goodsIndexService.updateIndexingToGoldPrice();
    }


    @ApiOperation(value = "查询商品-根据商品id")
    @RequestMapping(value = "/selectByGoodsIDs", method = RequestMethod.POST)
    public Object selectByGoodsIDs(@RequestBody List<Long> goodsIDs) {
        return goodsService.selectByGoodsIDs(goodsIDs);
    }

    @ApiOperation(value = "查询商品-根据商品id,2018小商城版")
    @RequestMapping(value = "/selectByGoodsIDsShop/{shopID}", method = RequestMethod.POST)
    public Object selectByGoodsIDsShop(@RequestBody List<Long> goodsIDs, @PathVariable Long shopID) {
        return goodsService.selectByGoodsIDsShop(goodsIDs, shopID);
    }

    @ApiOperation(value = "店铺版本2018：查询店铺商品列表")
    @RequestMapping(value = "/selectShopList/{pageNum}/{pageSize}", method = RequestMethod.POST)
    public Object selectShopList(@PathVariable int pageNum, @PathVariable int pageSize, @RequestBody QueryGoodsDto queryGoodsDto) {
        queryGoodsDto.setState(6);
        queryGoodsDto.setShopID(queryGoodsDto.getSupplierID());
        queryGoodsDto.setSupplierID(null);
        return goodsService.conditionQueryShopGoods(queryGoodsDto, pageNum, pageSize);
    }


    @ApiOperation(value = "店铺版本2018：获取平台商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "pageSize", required = true, value = "分页大小", defaultValue = "5"),
            @ApiImplicitParam(paramType = "path", name = "pageNum", required = true, value = "当前页", defaultValue = "1"),
    })
    @RequestMapping(value = "/listV2/{pageNum}/{pageSize}", method = RequestMethod.POST)
    public Object conditionQueryGoodsV2(@RequestBody QueryGoodsDto queryGoodsDto,
                                        @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        queryGoodsDto.setCompanyID(SystemContext.getCompanyID());
        queryGoodsDto.setShopID(queryGoodsDto.getSupplierID());
        queryGoodsDto.setSupplierID(null);
        return goodsService.conditionQueryGoods(queryGoodsDto, pageNum, pageSize);
    }

    @ApiOperation(value = "店铺版本2018：获取平台商品列表：可上架商品:已上架商品")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "pageSize", required = true, value = "分页大小", defaultValue = "5"),
            @ApiImplicitParam(paramType = "path", name = "pageNum", required = true, value = "当前页", defaultValue = "1"),
    })
    @RequestMapping(value = "/listV3/{pageNum}/{pageSize}", method = RequestMethod.POST)
    public Object conditionQueryGoodsV3(@RequestBody QueryGoodsDto queryGoodsDto,
                                        @PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        queryGoodsDto.setCompanyID(SystemContext.getCompanyID());
        //queryGoodsDto.setSupplierID(null);
        return goodsService.conditionQueryGoodsV2(queryGoodsDto, pageNum, pageSize);
    }


    @ApiOperation(value = "店铺版本2018：店长挑单件平台商品")
    @RequestMapping(value = "/copy", method = RequestMethod.POST)
    public Object copyGoods(@RequestBody GoodsDetailsVo goodsDetailsVo) {
        return goodsService.copyGoods(goodsDetailsVo);
    }

    @ApiOperation(value = "店铺版本2018：店长挑批量平台商品")
    @RequestMapping(value = "/batchCopy", method = RequestMethod.POST)
    public Object batchCopyGoods(@RequestBody BatchOnsaleDto batchOnsaleDto) {
        return goodsService.batchCopyGoods(batchOnsaleDto);
    }

    @ApiOperation(value = "店铺版本2018：批量操作商品状态")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "state", required = true, value = "商品状态(Approved:通过 Unapprove:未通过 Unshelve:下架 Shelve:上架 Detele:删除)", defaultValue = "Unapprove"),
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
    })
    @RequestMapping(value = "/states/{state}/{shopID}", method = RequestMethod.POST)
    public Object operateGoodsStateBatch(@RequestBody List<Long> goodsIDs, @PathVariable String state, @PathVariable Long shopID) {
        GoodsStateEnum stateEnum = Enum.valueOf(GoodsStateEnum.class, state);
        return goodsService.operateGoodsStateBatch(goodsIDs, stateEnum, shopID);
    }


    @ApiOperation(value = "查看商品详情v2;shopID, 2018")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
            @ApiImplicitParam(paramType = "path", name = "shopID", required = true, value = "shopID", defaultValue = "X123")
    })
    @RequestMapping(value = "/detailv2/{goodsID}/{shopID}", method = RequestMethod.GET)
    public Object queryGoodsDetailv3(@PathVariable Long goodsID, @PathVariable Long shopID, HttpServletRequest request) {

        return goodsService.queryShopGoodsDetail(goodsID, shopID);
    }


    @ApiOperation(value = "查看商品详情v2;shopID, 2018  type 0未上架 1已上架")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
            @ApiImplicitParam(paramType = "path", name = "shopID", required = true, value = "shopID", defaultValue = "X123"),
            @ApiImplicitParam(paramType = "path", name = "type", required = true, value = "type(0未上架1已上架)", defaultValue = "0")
    })
    @RequestMapping(value = "/detailv3/{goodsID}/{shopID}/{type}", method = RequestMethod.GET)
    public Object queryGoodsDetailv3(@PathVariable Long goodsID, @PathVariable Long shopID, @PathVariable Integer type, HttpServletRequest request) {

        return goodsService.queryShopGoodsDetailV2(goodsID, shopID, type);
    }


    @ApiOperation(value = "查询 shop sku信息. 2018")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "goodsID", required = true, value = "商品ID", defaultValue = "X123"),
    })
    @RequestMapping(value = "/sku/{goodsID}/{shopID}/{classifyID}", method = RequestMethod.GET)
    public Object queryGoodsShopSkuInfo(@PathVariable Long goodsID, @PathVariable Long shopID, @PathVariable String classifyID) {
        return goodsService.queryGoodsSkuInfo(goodsID, shopID, classifyID);
    }


    @ApiOperation(value = "查询店铺商品-价格集合 2018")
    @RequestMapping(value = "/priceListShop/{shopID}", method = RequestMethod.POST)
    public Object operateGoodsSkuPriceShop(@RequestBody List<Long> goodsIDs, @PathVariable Long shopID) {
        return goodsService.queryMultipleGoodsPriceShop(goodsIDs, shopID);
    }


    @ApiOperation(value = "根据一级分类查询需要高级搜索的分类  返回结果字符串如:abc,bcd")
    @RequestMapping(value = "/queryHighQueryClazzID", method = RequestMethod.GET)
    public Object queryHighQueryClazzID() {
        return goodsService.queryHighQueryClazzID();
    }

    @ApiOperation(value = "根据平台获取分类下需要高级查询的属性列表")
    @RequestMapping(value = "/highQueryAttrList", method = RequestMethod.POST)
    public Object getHighQueryAttrList(@RequestBody ClazzObjDto list) {
        return goodsService.getHighQueryAttrList(list);
    }

    /*@ApiOperation(value = "复制蓝蒂供应商商品到新公司")
    @RequestMapping(value = "/moveGoodsByCompany", method = RequestMethod.POST)
    public Object moveGoodsByCompany(@RequestBody MoveGoodsByCompanyDto moveGoodsByCompanyDto) {
        return goodsService.moveGoodsByCompany(moveGoodsByCompanyDto);
    }

    @ApiOperation(value = "删除商品到新公司")
    @RequestMapping(value = "/deleteGoodsByCompany/{supplierID}/{classifyID}/{subClassifyID}/{companyID}", method = RequestMethod.GET)
    public Object deleteGoodsByCompany(@PathVariable Long supplierID, @PathVariable String classifyID, @PathVariable String subClassifyID,@PathVariable Long companyID) {
        return goodsService.deleteGoodsByCompany(supplierID,classifyID,subClassifyID,companyID);
    }*/

    @ApiOperation(value = "商品属性调整")
    @RequestMapping(value = "/attrAdjust", method = RequestMethod.POST)
    public Object attrAdjust(@RequestBody MoveGoodsByCompanyDto moveGoodsByCompanyDto) {
        return goodsService.attrAdjust(moveGoodsByCompanyDto);
    }


    @ApiOperation(value = "商城商品分类标签列表")
    @RequestMapping(value = "/tagList/{clazzId}", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "clazzId", required = true, value = "分类ID，通常为一级分类", defaultValue = "X123")
    })
    public Object getGoodsClazzTagList(@PathVariable String clazzId) {
        return goodsService.getGoodsClazzTagList(clazzId);

    }

    @ApiOperation(value = "根据商城商品分类标签获取商品列表")
    @RequestMapping(value = "/goodsListByTag", method = RequestMethod.POST)
    public Object goodsListByTag(@RequestBody ClazzObjDto list) {
        return goodsService.getHighQueryAttrList(list);
    }


    @ApiOperation(value = "设置促销价  {\"goodsInfoVo\": { \"goodsID\": 0, \"shopID\": 0 },\"goodsSkuList\": [{\"price\": 100, \"skuID\": 1 },{ \"price\":200,\"skuID\": 2 }]}")
    @RequestMapping(value = "/origPrice", method = RequestMethod.POST)
    public Object setOrigPrice(@RequestBody GoodsDetailsVo goodsDetailsVo) {
        return goodsService.setOrigPrice(goodsDetailsVo);
    }

}
